package com.khiker.utils;

import java.util.TreeSet;

public class RandomUtils {

    public static Integer[] randomAscArray(int min, int max, int minLength, int maxLength) {
        int length = randomInt(minLength, maxLength);
        Integer[] result = new Integer[length];
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 0; i < length; i++) {
            set.add(randomInt(min, max));
        }
        return set.toArray(result);
    }


    public static int randomInt(int min, int max) {
        Integer random = null;
        while (random == null || random < min) {
            random = (int) (Math.random() * max);
        }
        return random;
    }
}
